home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1011 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.2 KB

  1. From: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
  2. Message-ID: <4kd143$op9@mulga.cs.mu.OZ.AU>
  3. X-Original-Date: 9 Apr 1996 06:46:27 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 09 Apr 96 13:20:29 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: static members as members of a metaclass h
  9. Organization: Comp Sci, University of Melbourne
  10. References: <4jc5lt$doh@arl-news-svc-2.compuserve.com>     <4jckdc$ad6@engnews1.Eng.Sun.COM> <kywx3q1nox.fsf@gator.mit.edu>
  11. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  12.     iQBFAgUBMWpkLeEDnX0m9pzZAQFR+gF/ea5RP8HK9j6j6TRfNolCA8LhTY1hHX7+
  13.     ZUxJd7m9/3h/eBjzbmGDNrA9gXFTP39Y
  14.     =0Pyi
  15.  
  16. jgealow@mtl.mit.edu (Jeffrey C. Gealow) writes:
  17.  
  18. >In article <4jckdc$ad6@engnews1.Eng.Sun.COM> clamage@Eng.Sun.COM 
  19. >(Steve Clamage) writes:
  20. >
  21. >   I believe a reasonable solution to the problem of initialization of 
  22. >   non-local static data is not to use non-local static data!
  23. >
  24. >   Instead of a static data object or static class data member, use a 
  25. >   function with a local static object.
  26. >
  27. >But this adds the overhead of the function call mechanism to every use 
  28. >of the object.
  29.  
  30. A good compiler will inline the function, especially if you define
  31. it as `inline' and put the function definition in the header file.
  32. (If it is a non-member function, you need to declare it as `extern
  33. inline' to ensure that you get one copy of the static object.)
  34. Some compilers don't inline functions containing local static objects,
  35. but it is certainly possible to do so; if you have such a compiler, you
  36. should ask your compiler vendor to improve their compiler's inlining.
  37.  
  38. --
  39. Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
  40. WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
  41. PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.
  42. ---
  43. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  44. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  45. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  46. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  47. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  48.